package com.ruoyi.quartz.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.quartz.domain.BaseMenu;
import com.ruoyi.quartz.service.IBaseMenuService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/base/menu")
public class BaseMenuController extends BaseController {

    @Resource
    private IBaseMenuService iBaseMenuService;

    @GetMapping("/list")
    public AjaxResult list(BaseMenu baseMenu)
    {
        List<BaseMenu> list = iBaseMenuService.selectAll(baseMenu);
        return AjaxResult.success(list);
    }

    @GetMapping(value = "/{menu_id}")
    public AjaxResult getInfo(@PathVariable("menu_id") Integer menu_id)
    {
        return AjaxResult.success(iBaseMenuService.selectMenuById(menu_id));
    }

    @PostMapping
    public AjaxResult add(@Validated @RequestBody BaseMenu baseMenu)
    {
        return toAjax(iBaseMenuService.insertMenu(baseMenu));
    }


    @PutMapping
    public AjaxResult edit(@Validated @RequestBody BaseMenu baseMenu)
    {
        return toAjax(iBaseMenuService.updateMenu(baseMenu));
    }

    @DeleteMapping("/{menu_ids}")
    public AjaxResult remove(@PathVariable Integer[] menu_ids)
    {
        return toAjax(iBaseMenuService.deleteMenuByIds(menu_ids));
    }

}
